<template>
  <view v-if="url">
    <web-view :key="url" :webview-styles="webviewStyles" :src="url"></web-view>
  </view>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from '@vue/composition-api'
import { onLoad } from 'uni-composition-api'
import queryParams from '@/utils/queryParams'

export default defineComponent({
  setup() {
    const webviewStyles = {
      progress: {
        color: '#FF3333',
      },
    }
    const state = reactive({
      url: '',
    })

    onLoad((query: any) => {
      const { url, ...arg } = query
      state.url = decodeURIComponent(`${url + queryParams(arg)}`)
    })

    return { webviewStyles, ...toRefs(state) }
  },
})
</script>
<style lang="scss" scoped></style>
